{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "from IPython.core.interactiveshell import InteractiveShell\n",
    "InteractiveShell.ast_node_interactivity = \"all\"\n",
    "# 解决坐标轴刻度负号乱码\n",
    "plt.rcParams['axes.unicode_minus'] = False\n",
    "# 解决中文乱码问题\n",
    "plt.rcParams['font.sans-serif'] = ['Simhei']\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Channel</th>\n",
       "      <th>Region</th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>12669</td>\n",
       "      <td>9656</td>\n",
       "      <td>7561</td>\n",
       "      <td>214</td>\n",
       "      <td>2674</td>\n",
       "      <td>1338</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>7057</td>\n",
       "      <td>9810</td>\n",
       "      <td>9568</td>\n",
       "      <td>1762</td>\n",
       "      <td>3293</td>\n",
       "      <td>1776</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>6353</td>\n",
       "      <td>8808</td>\n",
       "      <td>7684</td>\n",
       "      <td>2405</td>\n",
       "      <td>3516</td>\n",
       "      <td>7844</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>13265</td>\n",
       "      <td>1196</td>\n",
       "      <td>4221</td>\n",
       "      <td>6404</td>\n",
       "      <td>507</td>\n",
       "      <td>1788</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>22615</td>\n",
       "      <td>5410</td>\n",
       "      <td>7198</td>\n",
       "      <td>3915</td>\n",
       "      <td>1777</td>\n",
       "      <td>5185</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Channel  Region  Fresh  Milk  Grocery  Frozen  Detergents_Paper  Delicassen\n",
       "0        2       3  12669  9656     7561     214              2674        1338\n",
       "1        2       3   7057  9810     9568    1762              3293        1776\n",
       "2        2       3   6353  8808     7684    2405              3516        7844\n",
       "3        1       3  13265  1196     4221    6404               507        1788\n",
       "4        2       3  22615  5410     7198    3915              1777        5185"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data=pd.read_csv('Wholesale customers data.csv')\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 查看数据缺失值---数据并没有缺失值，数据完整性比较好"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Channel             0\n",
       "Region              0\n",
       "Fresh               0\n",
       "Milk                0\n",
       "Grocery             0\n",
       "Frozen              0\n",
       "Detergents_Paper    0\n",
       "Delicassen          0\n",
       "dtype: int64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#查看数据分布情况，描述性统计"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Channel</th>\n",
       "      <th>Region</th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "      <td>440.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>1.322727</td>\n",
       "      <td>2.543182</td>\n",
       "      <td>12000.297727</td>\n",
       "      <td>5796.265909</td>\n",
       "      <td>7951.277273</td>\n",
       "      <td>3071.931818</td>\n",
       "      <td>2881.493182</td>\n",
       "      <td>1524.870455</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.468052</td>\n",
       "      <td>0.774272</td>\n",
       "      <td>12647.328865</td>\n",
       "      <td>7380.377175</td>\n",
       "      <td>9503.162829</td>\n",
       "      <td>4854.673333</td>\n",
       "      <td>4767.854448</td>\n",
       "      <td>2820.105937</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>55.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>25.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3127.750000</td>\n",
       "      <td>1533.000000</td>\n",
       "      <td>2153.000000</td>\n",
       "      <td>742.250000</td>\n",
       "      <td>256.750000</td>\n",
       "      <td>408.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>8504.000000</td>\n",
       "      <td>3627.000000</td>\n",
       "      <td>4755.500000</td>\n",
       "      <td>1526.000000</td>\n",
       "      <td>816.500000</td>\n",
       "      <td>965.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>16933.750000</td>\n",
       "      <td>7190.250000</td>\n",
       "      <td>10655.750000</td>\n",
       "      <td>3554.250000</td>\n",
       "      <td>3922.000000</td>\n",
       "      <td>1820.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>112151.000000</td>\n",
       "      <td>73498.000000</td>\n",
       "      <td>92780.000000</td>\n",
       "      <td>60869.000000</td>\n",
       "      <td>40827.000000</td>\n",
       "      <td>47943.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Channel      Region          Fresh          Milk       Grocery  \\\n",
       "count  440.000000  440.000000     440.000000    440.000000    440.000000   \n",
       "mean     1.322727    2.543182   12000.297727   5796.265909   7951.277273   \n",
       "std      0.468052    0.774272   12647.328865   7380.377175   9503.162829   \n",
       "min      1.000000    1.000000       3.000000     55.000000      3.000000   \n",
       "25%      1.000000    2.000000    3127.750000   1533.000000   2153.000000   \n",
       "50%      1.000000    3.000000    8504.000000   3627.000000   4755.500000   \n",
       "75%      2.000000    3.000000   16933.750000   7190.250000  10655.750000   \n",
       "max      2.000000    3.000000  112151.000000  73498.000000  92780.000000   \n",
       "\n",
       "             Frozen  Detergents_Paper    Delicassen  \n",
       "count    440.000000        440.000000    440.000000  \n",
       "mean    3071.931818       2881.493182   1524.870455  \n",
       "std     4854.673333       4767.854448   2820.105937  \n",
       "min       25.000000          3.000000      3.000000  \n",
       "25%      742.250000        256.750000    408.250000  \n",
       "50%     1526.000000        816.500000    965.500000  \n",
       "75%     3554.250000       3922.000000   1820.250000  \n",
       "max    60869.000000      40827.000000  47943.000000  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "column=data.columns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据预处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#在此使用Normalizer---使用方法同MinMaxScaler、StandardScaler\n",
    "from sklearn.preprocessing import Normalizer \n",
    "#请补全代码（10分）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.70833271, 0.53987376, 0.42274083, 0.01196489, 0.14950522,\n",
       "        0.07480852],\n",
       "       [0.44219826, 0.61470384, 0.59953989, 0.11040858, 0.20634248,\n",
       "        0.11128583],\n",
       "       [0.39655169, 0.5497918 , 0.47963217, 0.15011913, 0.2194673 ,\n",
       "        0.48961931],\n",
       "       ...,\n",
       "       [0.36446153, 0.38846468, 0.7585445 , 0.01096068, 0.37223685,\n",
       "        0.04682745],\n",
       "       [0.93773743, 0.1805304 , 0.20340427, 0.09459392, 0.01531   ,\n",
       "        0.19365326],\n",
       "       [0.67229603, 0.40960124, 0.60547651, 0.01567967, 0.11506466,\n",
       "        0.01254374]])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nor=Normalizer()\n",
    "x_nor=nor.fit_transform(data.iloc[:,2:])\n",
    "x_nor"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 适用轮廓系数找到最优K"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 0,\n",
       "       1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 0, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 0, 2,\n",
       "       2, 1, 0, 1, 0, 2, 0, 1, 2, 1, 0, 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1,\n",
       "       0, 1, 1, 0, 2, 0, 2, 2, 2, 0, 0, 0, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2,\n",
       "       1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 2, 1, 0, 1,\n",
       "       1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 0, 1, 1, 2, 1, 2,\n",
       "       1, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2,\n",
       "       1, 1, 1, 0, 1, 1, 2, 0, 2, 1, 0, 2, 2, 2, 1, 1, 1, 2, 1, 1, 0, 2,\n",
       "       1, 1, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2, 1,\n",
       "       1, 2, 0, 0, 1, 1, 1, 0, 2, 0, 0, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 2, 2, 1, 1, 1, 0, 0, 2, 0, 1, 2, 1, 1, 0, 1, 1, 1, 0, 1, 2,\n",
       "       2, 2, 2, 1, 2, 1, 0, 2, 2, 1, 2, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 2, 1, 0, 2, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1,\n",
       "       1, 2, 0, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 1, 1, 1, 0, 0, 2, 1, 0,\n",
       "       1, 2, 1, 2, 0, 1, 1, 0, 0, 0, 2, 2, 2, 2, 0, 2, 2, 1, 1, 2, 0, 2,\n",
       "       2, 2, 1, 2, 1, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 2, 1, 1, 2, 1, 1, 1, 0, 2, 1, 2, 1, 1, 1, 0, 2, 2, 1, 1, 1,\n",
       "       2, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 0, 0, 2, 2, 2,\n",
       "       2, 1, 2, 1, 1, 1, 1, 0, 2, 1, 2, 1, 2, 0, 1, 2, 1, 1, 1, 2, 1, 2],\n",
       "      dtype=int32)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.cluster import KMeans\n",
    "clust=KMeans(n_clusters=3,random_state=0).fit(x_nor)\n",
    "y_pre=clust.labels_\n",
    "y_pre"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.cluster import KMeans \n",
    "from sklearn.metrics import silhouette_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.57508847, 0.23324504, 0.27925177, 0.6254248 , 0.05374771,\n",
       "        0.10905186],\n",
       "       [0.9024623 , 0.17915962, 0.22911268, 0.14969506, 0.04904731,\n",
       "        0.07445492],\n",
       "       [0.25411803, 0.48606066, 0.68466474, 0.09572091, 0.27138443,\n",
       "        0.09719618]])"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "centid=clust.cluster_centers_#获得质心坐标\n",
    "centid"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "45.950577045688064"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#整体距离平方和\n",
    "inertia=clust.inertia_\n",
    "inertia"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.4478262043812748"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#计算得到所有样本的得分的均值\n",
    "silhouette_score(x_nor,y_pre)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x11d373520>]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png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E59x/H2G0pcFvgyPWZQLVzble3hQxSMGMxs4GfzZma2WRaX7OQ+4doZhlmlhK4nAhcAnzcbrelwJzA5euAP7kQ/MReMGNpN196Na3HV0KKc+77zrlM51wuMJvWv+9b2u0WFq9JMGMJh9cEwMx6BRZfYGa9gEuBde1269QOC8dVN2cDtwIfBeZQAf4JyAZwzv0GWAZcDmwBaoHbuz9mUIIZy3XAV82sCagDZofiP0RgELDAzKJp/WX0nHPuZTN7CCh2zi2l9Zfak2a2Baii9R9sKApmLP9gZlfTunKqCij0LG0HhelrclRh+poMABYH3r/FAM845141s69A13SYToEgIhLhwm7qRkREOkZFLyIS4VT0IiIRTkUvIhLhVPQiIhFORS8iEuFU9CIiEe5/AXE55W8HJJRbAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#找最优的k\n",
    "score=[]\n",
    "\n",
    "for i in range(2,6):\n",
    "    cluster = KMeans(n_clusters=i, random_state=0).fit(x_nor)\n",
    "    score.append(silhouette_score(data,cluster.labels_))\n",
    "plt.plot(range(2,6),score)\n",
    "#最高的位置增加一条虚线\n",
    "# plt.axvline(pd.DataFrame(score).idxmax()[0]+2,ls=':')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#最高分的索引\n",
    "pd.DataFrame(score).idxmax()[0]+2#最优的k"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 建模及可视化分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Channel', 'Region', 'Fresh', 'Milk', 'Grocery', 'Frozen',\n",
       "       'Detergents_Paper', 'Delicassen'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "column"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Fresh</th>\n",
       "      <th>Milk</th>\n",
       "      <th>Grocery</th>\n",
       "      <th>Frozen</th>\n",
       "      <th>Detergents_Paper</th>\n",
       "      <th>Delicassen</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.869573</td>\n",
       "      <td>0.174954</td>\n",
       "      <td>0.226061</td>\n",
       "      <td>0.224904</td>\n",
       "      <td>0.050075</td>\n",
       "      <td>0.074002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.264083</td>\n",
       "      <td>0.479221</td>\n",
       "      <td>0.661907</td>\n",
       "      <td>0.134295</td>\n",
       "      <td>0.251450</td>\n",
       "      <td>0.105409</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Fresh      Milk   Grocery    Frozen  Detergents_Paper  Delicassen\n",
       "0  0.869573  0.174954  0.226061  0.224904          0.050075    0.074002\n",
       "1  0.264083  0.479221  0.661907  0.134295          0.251450    0.105409"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cluster = KMeans(n_clusters=2, random_state=420).fit(x_nor)\n",
    "data_a=pd.DataFrame(cluster.cluster_centers_,columns=list(column[2:]))\n",
    "data_a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0.568182\n",
       "1    0.431818\n",
       "dtype: float64"
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pre=pd.Series(cluster.labels_)\n",
    "y_pre.value_counts(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([<matplotlib.patches.Wedge at 0x12c862100>,\n",
       "  <matplotlib.patches.Wedge at 0x12c8627f0>],\n",
       " [Text(-0.2338218002108559, 1.0748615565486352, ''),\n",
       "  Text(0.23382180021085577, -1.0748615565486352, '')],\n",
       " [Text(-0.12753916375137594, 0.586288121753801, '57%'),\n",
       "  Text(0.12753916375137586, -0.586288121753801, '43%')])"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x12ce0f8e0>"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOcAAADnCAYAAADl9EEgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAWlUlEQVR4nO3deZgU1b3G8W/1AgMIzSKLAlIaY0RRRBZ3MYkbjmg0Imi8MbhdTa5BEhLLXL0plYutEWPidQ1RY9wFImqhJq64AhLAEGRRaVkUAYGCYZi1+/5RDQKyzNLdv1Pdv8/z9OMM0H3eceadU9VVdcrKZDIopcwTkQ6glNo5LadShtJyKmUoLadShtJyKmU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BXGK+As7C9d+VDpJvpVNOADdxIsEtxTsIJ1FNswQYgusvlA5SCMW7z7kzrj8NOJZgCX4VLjOBY0qlmFBq5QRw/QVAf2CKdBTVYHcCx+P6X0oHKaTS2qzdkZv4OcEZRbofaqa1BAtyPScdREJplxPATfQDngK+LR1Fbecd4ILsDa1KUult1u7I9WcDR6InLJgiQ3DY66RSLibozLm94HDLnUBX4SSlaj5wJa7/lnQQE+jMua3gdnDfAe4mOANFFcZm4DfAEVrMr+nMuStuYgDBqX8DpKMUuanAf4Vxdbx803LujpuIEJxAPw5ICKcpNisIzo2dJB3EVFrOhnATXQg2u65ED7s012qCw1f34PqV0mFMpuVsDDfRk+BO2z8B4rJhQucr4HbgLlx/k3SYMNByNoWb6EWwHuol6Ey6J+uA8cAfcf2N0mHCRMvZHG5iH2AUwXWjXYTTmGYxcD/wJ1x/g3SYMNJy5oKbiAM/AK4Avk/pXjdaS3DVz33A69kVKVQTaTlzzU0cAFxGMJt2E05TKEsI1mx6sNROTs8nLWe+uIkYcCpwFjAU2Fc2UM4tJJglpwDv6yyZe1rOQnATFsH5u1uK2k82UJOkgfcJyjillK6rlKLllBAckjkVOAoYBPQBoqKZvikNfEhwdcg7wGu6yVpYWk4TuInWBBeAbylrf2A/CneLxiqC1SHmEtyx7QNglh76kKXlNFWwz9oDsHd49ALaA22A1tv8t8UOr1ADVACbtnn4wGcEt8dbss1jpe4zmkfLWSyCMrcmOIyzCdfXWyKGnJZTKUPp9ZxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGUrLqZShtJxKGer/AXteaH5NkxKFAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "y_pre=pd.Series(cluster.labels_)\n",
    "s=y_pre.value_counts(1).values\n",
    "labels=y_pre.value_counts(1).index\n",
    "plt.pie(s,autopct='%.f%%')\n",
    "plt.legend(labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 3 artists>"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 3 artists>"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 3 artists>"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 3 artists>"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 3 artists>"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "([<matplotlib.axis.XTick at 0x12c8721f0>,\n",
       "  <matplotlib.axis.XTick at 0x12c872160>,\n",
       "  <matplotlib.axis.XTick at 0x12c877790>],\n",
       " [Text(0, 0, ''), Text(0, 0, ''), Text(0, 0, '')])"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x12c1910d0>"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAZo0lEQVR4nO3de3BV5b3/8feXcAmC5acQKiVIsD9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AKNBFRAJCgS4iEhAKdBGRgFCgi4gEhAJdRCQgFOgiIgGhQBcRCQgFuohIQCjQRUQCQoEuIhIQCnQRkYBQoIuIBIQCXUQkIBToIiIBoUAXEQkIBbqISEAo0EVEAkKBLiISEAp0EZGACCvQzewqM9tmZnlmNqWC7U3MLKNk+8dmlhDxSkVEpFJVBrqZxQBzgauBLsBIM+tSrtkdwFfu/v+B3wJPRrpQERGpXDhn6KlAnrvvcvfDwBLg2nJtrgUWlrxeCgwwM4tcmSIiUhVz98obmF0PXOXud5YsjwZ6u/uEMm02lbQpKFneWdLmi3J93Q3cXbLYGdgWqQM5y7UCvqiylZwt9HnVPfXpM2vv7nEVbWh4Jqtw9/nA/DO5z7OBma1z957RrkPCo8+r7tFnViycIZc9QLsyy/El6ypsY2YNgRbAvkgUKCIi4Qkn0NcCHc2sg5k1Bm4ClpVrswwYU/L6emClVzWWIyIiEVXlkIu7HzWzCcBbQAzwkrtvNrMZwDp3Xwa8CPy3meUBX1Ic+vJv9W6YqY7T51X36DMjjC9FRUSkbtCdoiIiAaFAFxEJCAV6LapqygQ5u5jZS2a2t+S+CqkDzKydmb1rZrlmttnMHoh2TdGkMfRaUjJlwnZgIFBA8dVCI909N6qFySmZ2eVAEfAHd0+Mdj1SNTNrA7Rx92wzOxdYD1xXX/+d6Qy99oQzZYKcRdz9fYqv0pI6wt0/c/fsktffAluAttGtKnoU6LWnLbC7zHIB9fgvmkhtK5nltRvwcZRLiRoFuojUeWbWHPgz8At3/yba9USLAr32hDNlgojUkJk1ojjMF7n7X6JdTzQp0GtPOFMmiEgNlEzT/SKwxd2fiXY90aZAryXufhQ4MWXCFuBVd98c3aqkMma2GFgDdDazAjO7I9o1SZXSgNFAfzPLKfkzJNpFRYsuWxQRCQidoYuIBIQCXUQkIBToIiIBoUAXEQkIBbqISEAo0EVEAkKBLiISEP8H/887XhYp1uQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "size=3\n",
    "x=np.arange(size)\n",
    "a=data_a.iloc[:,0]\n",
    "b=data_a.iloc[:,1]\n",
    "c=data_a.iloc[:,2]\n",
    "d=data_a.iloc[:,3]\n",
    "e=data_a.iloc[:,4]\n",
    "label=column[2:]\n",
    "\n",
    "total_width, n = 0.8, 5\n",
    "width = total_width / 5\n",
    "x = x - (total_width - width) / 2\n",
    "\n",
    "plt.bar(x, a,  width=width, label=data_a.columns[0])\n",
    "plt.bar(x + width, b, width=width, label=data_a.columns[1])\n",
    "plt.bar(x + 2 * width, c, width=width, label=data_a.columns[2])\n",
    "\n",
    "plt.bar(x + 3 * width, c, width=width, label=data_a.columns[3])\n",
    "\n",
    "plt.bar(x + 4 * width, c, width=width, label=data_a.columns[4])\n",
    "plt.xticks([0,1,2])\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
